﻿using Microsoft.AspNetCore.Mvc;
using System;
using System.Collections.Generic;
using System.Threading.Tasks;
using Volo.Abp.AspNetCore.Mvc;
using YaAppoint.Appointments.TimeIntervals;

namespace YaAppoint.Web.Controllers
{
    public class TimeIntervalController(ITimeIntervalAppService timeIntervalAppService) : AbpController
    {
        private readonly ITimeIntervalAppService _timeIntervalAppService= timeIntervalAppService;

        /// <summary>
        /// 获取列表
        /// </summary>
        [HttpGet("/api/time-interval/get-list")]
        public async Task<IActionResult> GetListAsync(Guid sid, string? filterName,int page,int pageSize)
        {
            return new JsonResult(await _timeIntervalAppService.GetListAsync(sid,filterName,page,pageSize));
        }

        /// <summary>
        /// 提交新建
        /// </summary>
        [HttpPost("/api/timeInterval/submit-create")]
        public async Task<IActionResult> SubmitCreate([FromBody] CreateTimeIntervalDto dto, [FromQuery] Guid sid)
        {
            return new JsonResult(await _timeIntervalAppService.SubmitCreate(dto,sid));
        }

        [HttpPost("/api/time-interval/batch-create")]
        public async Task<IActionResult> BatchCreateAsync([FromBody] BatchCreateDto batchModel, [FromQuery] Guid sid)
        {
            return new JsonResult(await _timeIntervalAppService.BatchCreateAsync(batchModel,sid));
        }

        /// <summary>
        /// 提交编辑
        /// </summary>
        [HttpPost("/api/timeInterval/submit-edit")]
        public async Task<IActionResult> SubmitEidt([FromBody] TimeIntervalDto dto)
        {
            return new JsonResult(await _timeIntervalAppService.SubmitEidt(dto));
        }

        /// <summary>
        /// 获取详情
        /// </summary>
        [HttpGet("/api/timeInterval/get")]
        public async Task<IActionResult> GetAsync(Guid id)
        {
            return new JsonResult(await _timeIntervalAppService.GetAsync(id));
        }

        /// <summary>
        /// 启用/禁用
        /// </summary>
        [HttpGet("/api/timeInterval/toggle-disable")]
        public async Task<IActionResult> DisableToggle(Guid id)
        {
            return new JsonResult(await _timeIntervalAppService.DisableToggle(id));
        }

        /// <summary>
        /// 删除 
        /// </summary>
        [HttpDelete("/api/timeInterval/delete")]
        public async Task<IActionResult> Delete(Guid id)
        {
            return new JsonResult(await _timeIntervalAppService.Delete(id));
        }

        [HttpPost("/api/time-interval/delete-many")]
        public async Task<IActionResult> DeleteMany([FromBody]List<Guid> idList)
        {
            return new JsonResult(await _timeIntervalAppService.DeleteMany(idList));
        }

    }
}
